﻿using Coldairarrow.Business.Frontstage.BS_TransferLog;
using Coldairarrow.Entity.Frontstage.BS_TransferLog;
using Coldairarrow.Util;
using Microsoft.AspNetCore.Mvc;
using System.Collections.Generic;
using System.Threading.Tasks;

namespace Coldairarrow.Api.Controllers.Frontstage.BS_TransferLog
{
    [Route("/Frontstage/BS_TransferLog/[controller]/[action]")]
    public class BS_TransferController : BaseApiController
    {
        #region DI

        public BS_TransferController(IBS_TransferBusiness bS_TransferBus)
        {
            _bS_TransferBus = bS_TransferBus;
        }

        IBS_TransferBusiness _bS_TransferBus { get; }

        #endregion

        #region 获取

        [HttpPost]
        public async Task<PageResult<BS_Transfer>> GetDataList(PageInput<ConditionDTO> input)
        {
            return await _bS_TransferBus.GetDataListAsync(input);
        }

        [HttpPost]
        public async Task<BS_Transfer> GetTheData(IdInputDTO input)
        {
            return await _bS_TransferBus.GetTheDataAsync(input.id);
        }

        #endregion

        #region 提交

        [HttpPost]
        public async Task SaveData(BS_Transfer data)
        {
            if (data.Id.IsNullOrEmpty())
            {
                InitEntity(data);

                await _bS_TransferBus.AddDataAsync(data);
            }
            else
            {
                await _bS_TransferBus.UpdateDataAsync(data);
            }
        }

        [HttpPost]
        public async Task DeleteData(List<string> ids)
        {
            await _bS_TransferBus.DeleteDataAsync(ids);
        }

        #endregion
    }
}